﻿

using SqlSugar;

namespace Test
{
    public class SqlSugarHelper
    {
            
        public static SqlSugarClient Db()
        {
            SqlSugarClient DbClient = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString = "server=175.178.106.122;uid=long;pwd=long.1131150912.;database=Basara",
                DbType = DbType.SqlServer,
                IsAutoCloseConnection = true

            },
            DbClient => {

                DbClient.Aop.OnLogExecuting = (sql, pars) =>
                {

                    //获取原生SQL推荐 5.1.4.63  性能OK
                    // 输出sql语句
                    Console.WriteLine(UtilMethods.GetNativeSql(sql, pars));

                    //获取无参数化SQL 对性能有影响，特别大的SQL参数多的，调试使用
                    //Console.WriteLine(UtilMethods.GetSqlString(DbType.SqlServer,sql,pars))


                };

                //注意多租户 有几个设置几个
                //db.GetConnection(i).Aop


            });

            return DbClient;

        }

       
    }


}
